Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-9366: Change log4j dependency into log4j2 #7898

Closed
wants to merge 9 commits into from

Conversation

dongjinleekr
Copy link
Contributor

This PR changes log4j dependency into log4j2.

log4j migrated into log4j2 after its last release of 1.2.17 (May 2012), which is affected by this problem. So, the only way to fix it is by moving log4j dependency into log4j2.

The problem is: the API for setting log level dynamically is different between log4j and log4j2. So, this PR also updates how Log4jController works.

This PR also fixes a potential problem in Log4jController#getLogLevel - what if the root logger's level is null? It may result in NullPointerException.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@dongjinleekr
Copy link
Contributor Author

@ijuma
Copy link
Member

ijuma commented Jan 7, 2020

This requires a KIP since the log4j2 config is not compatible with log4j.

@dongjinleekr
Copy link
Contributor Author

@ijuma No problem. Thank you for your guidance. 😄 Stay tuned!

@rgoers
Copy link
Member

rgoers commented Jan 14, 2020

Log4J 2.13.0 contains experimental support for some Log4J 1 Configuration flies. See http://logging.apache.org/log4j/2.x/manual/compatibility.html.

@ijuma
Copy link
Member

ijuma commented Jan 14, 2020

That's awesome, thanks for sharing.

@akamensky
Copy link

I just had to deal with configuring filtered logs in Kafka and was shocked to find it uses log4j 1.2.17.

log4j v1 has been dead since 2015. 5 years ago it was known that it should not be used for any new designs and applications should migrate to v2, yet still Apache Kafka stuck with that?

Wanted to raise a ticket, but there is this PR, which does not seem to be getting merged anywhere... dear lord...

@dongjinleekr
Copy link
Contributor Author

@akamensky I am sorry to hear that. I am almost done the KIP and will start the discussion next week. If you are interested in this issue, please join in. Have a nice weekend.

@OneCricketeer
Copy link

Man, I really wish more Apache projects started this "upgrade"

@dongjinleekr
Copy link
Contributor Author

@Cricket007 Sorry for the delay.

While working on this issue, I found that this upgrade is much more complicated than I first expected; It is related to lots of module dependencies, API changes, test code modification, and providing backward-compatibility for the logging configuration. Anyway, it is almost done. I successfully upgraded the whole project and now working with some race conditions on test suites.

I hope I can complete it in a couple of days. 😉 @akamensky

@OneCricketeer
Copy link

No worries. I didn't realize the backwards compatible issues either. I was under the impression that slf4j bridges handled that. Personally, I've been using logback successfully for years

@OneCricketeer
Copy link

OneCricketeer commented Mar 27, 2020

So, I'm actually working on a project that I just started...

Can verify (part of) this log4j-slf4j + slf4j-log4j12 bridging definitely works without issue

https://github.com/cricket007/kafka-streams-jib-example/blob/feature/connect-distributed/pom.xml#L67-L91

Notice too

        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

import org.apache.log4j.{Level, LogManager, Logger}
import org.apache.logging.log4j.{Level, LogManager}
import org.apache.logging.log4j.core.config.Configurator
import org.apache.logging.log4j.core.LoggerContext

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, why not rewrite against org.slf4j?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log4jController provides a dynamic Logger querying functionality, not logging itself. It is why it uses log4j Loggers directly.

In contrast, the streams module does not provide those kinds of functionality so it uses slf4j fascade.

@@ -77,7 +77,7 @@ versions += [
jersey: "2.28",
jmh: "1.21",
hamcrest: "2.1",
log4j: "1.2.17",
log4j: "2.12.1",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the comments, how about 2.13.x?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cricket007 Yes, I am now working with 2.13.1 and it seems like good.

@dongjinleekr
Copy link
Contributor Author

Here is the WIP update. I almost completed the migration into log4j2 2.13.1 but here are some issues:

  1. I migrated all test methods into logj42 API, using the way Log4j2 itself does; However, I failed to migrate StateManagerUtilTest. It seems like this class is tightly coupled with Kafka Streams' slf4j logging mechanism, but I don't understand it yet.
  2. The updated test suites working correctly when running individually, but if run at once (e.g., ./gradlew :streams:test), some test suites go so flaky.

I am also tracking down the reason. If you can give me some advice, it will be a great help! 😃

Copy link

@OneCricketeer OneCricketeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass

@@ -276,10 +280,7 @@
<allow pkg="kafka.utils" />
<allow pkg="org.apache.zookeeper" />
<allow pkg="org.apache.zookeeper" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Zookeeper duplicated here??

Also, does Zookeeper transitively bring in log4j anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplication has been addressed in this PR.

Since this setting contols only direct imports only, it does not bring log4j transitively.

import java.util.Objects;
import java.util.TreeMap;
import org.apache.kafka.connect.errors.NotFoundException;
import org.apache.kafka.connect.runtime.rest.errors.BadRequestException;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems org.apache.kafka.* imports used to be first

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Please have a look at this PR. :)

Comment on lines 65 to 67
.map(logger -> new AbstractMap.SimpleEntry<>(logger.getName(), configLevelToMap(logger)))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the .map() needed?

Suggested change
.map(logger -> new AbstractMap.SimpleEntry<>(logger.getName(), configLevelToMap(logger)))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
.collect(Collectors.toMap(logger -> logger.getName(), logger -> configLevelToMap(logger));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, Collectors.toCollection(Treeset::new) might be useful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. I will apply it. :)

throw new NotFoundException("Logger " + namedLogger + " not found.");
Optional<Logger> found = currentLoggers()
.stream()
.filter(logger -> loggerName.equals(logger.getName()))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can logger == null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. log4j2 does not allow logger == null.

Comment on lines 26 to 20
import org.apache.kafka.connect.errors.NotFoundException;
import org.apache.kafka.connect.runtime.rest.errors.BadRequestException;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems these imports used to be first

Objects.requireNonNull(loggerLevels);

final LoggerContext loggerContext = Configurator.initialize(LoggingResourceTest.class.getName(),
null, new File("src/test/resources/log4j2.properties").getAbsolutePath());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally, rather than rely on src/test/resources, I would pull from the classpath... LoggingResourceTest.class.getClassLoader().getResource("log4j2.properties")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I will have a try.

@@ -78,6 +78,7 @@ versions += [
jmh: "1.23",
hamcrest: "2.2",
log4j: "1.2.17",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet. log4j-appender is still using log4j; log4j2-appender is under progress. :)

@@ -165,6 +166,10 @@ libs += [
kafkaStreams_23: "org.apache.kafka:kafka-streams:$versions.kafka_23",
kafkaStreams_24: "org.apache.kafka:kafka-streams:$versions.kafka_24",
log4j: "log4j:log4j:$versions.log4j",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto 😃

appender.console.type=Console
appender.console.name=STDOUT
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d{HH:mm:ss,SSS} %-5p %-60c %x - %m%n

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern looks different

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the reason is that it follows deleted quickstart/java/src/main/resources/archetype-resources/src/main/resources/log4j.properties; it has different pattern so I followed it.

import java.util.Locale;
import java.util.Map;
import java.util.Properties;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these got rearranged

@tombentley
Copy link
Contributor

@dongjinleekr I hadn't realised you were working on this via KAFKA-9366. I was looking at it via KAFKA-1368. You've made more progress than me, so happy for you to take it forward. But there are a couple of issues I noticed in the course of my effort:

  1. The Log4jControllerMBean.getLoggers returns a scala wrapper implementation of java.util.List, which means that JMX tools (e.g. jvisualvm) can't deserialize the list unless they have scala library on their classpath. That's easily fixed by returning a java.util.ArrayList copy of the list.

  2. I suspect you already know this, but with log4j there were loggers for things like kafka.controller because they appeared in the config file, even though a logger with that name was never created in the code. Because log4j2 separates loggers and logger configurations the call logContext.getLoggers only returns the loggers created in code. So AFAICS you won't be able to change the log level for kafka.controller, and would have to change the level of all descendant loggers individually. I guess this is a regression, since Log4jController is used for AlterConfigs RPC.

@dongjinleekr
Copy link
Contributor Author

Here is the update, with rebasing onto the latest trunk. Now all tests run properly. However, it still has a problem:

When I ran the test suites individually (e.g., ./gradlew :streams:test --tests org.apache.kafka.streams.KafkaStreamsTest) all tests passes clearly. However, if I tried to run them in package-wide (e.g., ./gradlew :streams:test --tests org.apache.kafka.streams.internal.*) or all-in-once (e.g., ./gradlew :streams:test) the tests go so flaky and some tests fail, with one of the following error messages:

// Type 1: Can't find LIST appender.
java.lang.AssertionError: No ListAppender named LIST found.
  at org.apache.logging.log4j.junit.LoggerContextRule.getListAppender(LoggerContextRule.java:210)
  at org.apache.kafka.streams.state.internals.AbstractKeyValueStoreTest.before(AbstractKeyValueStoreTest.java:71)
  at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
// Type 2: the log message did not forwarded to the List appender.
java.lang.AssertionError: 
Expected: a collection containing "INFO Opening store db-name in upgrade mode "
     but: mismatches were: [was "..."]
  at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
  at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
  at org.apache.kafka.streams.state.internals.RocksDBTimestampedStoreTest.shouldMigrateDataFromDefaultToTimestampColumnFamily(RocksDBTimestampedStoreTest.java:139)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

To understand these errors, here is a background: To validate the logging messages, Kafka has been used a test Appender (i.e., ListAppender here) attached to the root logger. Although this PR updates log4j 1.x to 2.x, the overall approach has not changed.

This approach works well when running individually, but when running in batch, the test suite randomly fails to initialize the ListAppender (Type 1 error) or forward the log message to ListAppender(Type 2 error); I ran the tests more than a hundred of times but What I found was it is totally random and be affected by gradle's maxParallelForks parameter - it seems like there is a problem deep inside of log4j here.

I have been working on this issue for the last week could not find any perfect solution. If any of you have some ideas on this, it would be a great help. Thanks in advance. 😃

@dongjinleekr
Copy link
Contributor Author

@tombentley Thanks for your valuable comments - absoultely it will be a great help! I am now applying the comments from @Cricket007 so as soon as it is completed I will review your comments again and leave a feedback. 😄

@OneCricketeer
Copy link

I've written test appenders in other projects just to verify contents of log messages, but not really sure the implications of race conditions on that.

@dongjinleekr
Copy link
Contributor Author

@Cricket007 It seems like we need to consult to log4j mailing list. Okay, I will have a try.

@OneCricketeer
Copy link

@jeffhuang26
Copy link
Contributor

What is timeline for merging this PR?

@ijuma
Copy link
Member

ijuma commented May 29, 2020

@dongjinleekr Can please submit a KIP for this? We should have a better good idea of the compatibility implications by now, right?

@ijuma
Copy link
Member

ijuma commented May 29, 2020

Oh, I had missed the comment about the errors we are seeing when running the tests. It may be worth upgrading to the latest release in case it has been fixed.

@dongjinleekr
Copy link
Contributor Author

All // Sorry for being late, I just got out from my last project; I will have a look at this PR this weekend.

@dongjinleekr dongjinleekr force-pushed the feature/KAFKA-9366 branch 3 times, most recently from 6f4fd96 to 4c24cf2 Compare June 24, 2020 09:13
@dongjinleekr
Copy link
Contributor Author

Here is the fix. I completed to implement all the features, migrating tests to follow log4j2 API, and rebasing onto the latest trunk, but there is a problem in logging message validation.

gradle-fail

When I run :stream:test task in my dev environment, the following 10 tests fail:

  • StreamsConfigTest: shouldLogWarningWhenPartitionGrouperIsUsed
  • KStreamKTableJoinTest: shouldLogAndMeterWhenSkippingNullLeft[Key,Value]WithBuiltInMetricsVersion[Latest,0100To24]
  • InMemorySessionStoreTest: shouldLogAndMeasureExpiredRecordsWithBuiltInMetricsVersion[Latest,0100To24], shouldNotThrowInvalidRangeExceptionWithNegativeFromKey
  • RocksDBTimestampedStoreTest: shouldMigrateDataFromDefaultToTimestampColumnFamily, shouldOpenNewStoreInRegularMode

However, If I run the test suites StreamsConfigTest, KStreamKTableJoinTest, and InMemorySessionStoreTest individually, they work fine.

And if I run RocksDBTimestampedStoreTest test suite, it fails; the expected log message does not forwarded to the appender.

2

In contrast, if I run the test methods individually, they also work fine:

1

It seems like there is a problem with log4j in forwarding the log message to the appender. (Or is the appender closed before the log message arrives?) But I can't certain; I followed the way log4j2 test suites do, but could not find similar cases in their codebase.

I tried to fix this problem for several days but not succeeded. If you have some spare time, could you check out this PR and run the tests on your machine? I am working with Ubuntu 20.04 + OpenJDK 8. I am curious the same tests also fail in the other environments.

cc/ @ijuma @OneCricketeer @jeffhuang26

Copy link
Contributor

@showuon showuon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a 1st pass to the changes above RocksDBTimestampedStoreTest.java. Will continue to review the remaining code changes. Thanks.

try (final LogCaptureAppender appender = LogCaptureAppender.createAndRegister(KafkaStreams.class);
final KafkaStreams streams = new KafkaStreams(builder.build(), props, supplier, time)) {
try (final LogCaptureContext logCaptureContext = LogCaptureContext.create();
final KafkaStreams streams = new KafkaStreams(builder.build(), props, supplier, time)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = STDOUT

status = error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

@showuon showuon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dongjinleekr , I've had a first pass to all the files. Thanks for the work!
In addition to the comments left, some high level comments:

  1. Please rebase to the latest trunk to fix merge conflict
  2. I think we should run a system test and Trogdor test to make sure this change won't break existing tests.

Thank you.

Comment on lines +70 to 77
try (final LogCaptureContext logCaptureContext = LogCaptureContext.create()) {
logCaptureContext.setLatch(3);

// re-open store
try (final LogCaptureAppender appender = LogCaptureAppender.createAndRegister(RocksDBTimestampedStore.class)) {
// prepare store
rocksDBStore.init((StateStoreContext) context, rocksDBStore);

assertThat(appender.getMessages(), hasItem("Opening store " + DB_NAME + " in regular mode"));
} finally {
rocksDBStore.put(new Bytes("key".getBytes()), "timestamped".getBytes());
rocksDBStore.close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we remove finally block for rocksDBStore.close()? Is there possible that we have resource leak here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The try block with LogCaptureAppender resource was removed; That's the reason.

Comment on lines 426 to 439
try (LogCaptureAppender appender = LogCaptureAppender.createAndRegister(RocksDBTimestampedStore.class)) {
rocksDBStore.init((StateStoreContext) context, rocksDBStore);

assertThat(appender.getMessages(), hasItem("Opening store " + DB_NAME + " in upgrade mode"));
} finally {
rocksDBStore.close();
}
rocksDBStore.init((StateStoreContext) context, rocksDBStore);
assertThat(logCaptureContext.getMessages(), hasItem("INFO Opening store " + DB_NAME + " in upgrade mode "));
rocksDBStore.close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto: potential resource leak?

@infa-rbliznet
Copy link

Is there any progress on it? According to this: https://cwiki.apache.org/confluence/display/KAFKA/Release+Plan+3.2.0 , KIP should be completed by March 2 and Feature freeze is on March 16.

@dongjinleekr dongjinleekr force-pushed the feature/KAFKA-9366 branch 3 times, most recently from 40ec27e to 5d2fae2 Compare March 18, 2022 14:13
@dongjinleekr
Copy link
Contributor Author

@showuon Here is the update, rebasing onto the latest trunk. 🙇

@edoardocomar
Copy link
Contributor

Hi @dongjinleekr would you consider this patch to fix the compilation error

diff --git streams/src/test/java/org/apache/kafka/streams/StreamsConfigTest.java streams/src/test/java/org/apache/kafka/streams/StreamsConfigTest.java
index 2bfbe4e36b..3cbb5c6369 100644
--- streams/src/test/java/org/apache/kafka/streams/StreamsConfigTest.java
+++ streams/src/test/java/org/apache/kafka/streams/StreamsConfigTest.java
@@ -1039,7 +1039,9 @@ public class StreamsConfigTest {
     @Test
     public void shouldSpecifyRocksdbWhenNotExplicitlyAddedToConfigs() {
         final String expectedDefaultStoreType = StreamsConfig.ROCKS_DB;
-        final String actualDefaultStoreType = streamsConfig.getString(DEFAULT_DSL_STORE_CONFIG);
+        props.put(DEFAULT_DSL_STORE_CONFIG, expectedDefaultStoreType);
+        final StreamsConfig config = new StreamsConfig(props);
+        final String actualDefaultStoreType = config.getString(DEFAULT_DSL_STORE_CONFIG);
         assertEquals("default.dsl.store should be \"rocksDB\"", expectedDefaultStoreType, actualDefaultStoreType);
     }

@dongjinleekr
Copy link
Contributor Author

Rebased onto the latest trunk. cc/ @edoardocomar

@dhruvp-8
Copy link

@dongjinleekr Thanks for working on this PR. Is there a timeline on when will this be merged? As per this doc https://cwiki.apache.org/confluence/display/KAFKA/Release+Plan+3.2.0 is it pushed to Kafka 3.3?

1. Update Dependency Configuration (except log4j-appender, shell, and tools)

  1. Change log4j into log4j2 (1.2.7 → 2.14.1)
  2. Change log4j dependency into log4j-api + log4j-core
  3. Change slf4j-log4j12 dependency into log4j-slf4j-impl
  4. Add log4j-1.2-api dependency for backward-compatibility

2. Update core

  1. Update Log4jController to use log4j2. (PlaintextAdminIntegrationTest also changed for API change.)
  2. Test logging config changed: core/src/test/resources/log4j.properties → core/src/test/resources/log4j2.properties
  3. Logging test class changed: LogCaptureAppender → LogCaptureContext, LoggingUtil
  4. Enable ignored tests in PlaintextAdminIntegrationTest

3. Update client

  1. Test logging config changed: client/src/test/resources/log4j.properties → client/src/test/resources/log4j2.properties

3. Update connect:mirror

  1. Test logging config changed: connect/mirror/src/test/resources/log4j.properties → connect/mirror/src/test/resources/log4j2.properties

4. Update connect:runtime

  1. Update LoggingResource to use log4j2.
  2. Test logging config changed: connect/runtime/src/test/resources/log4j.properties → connect/runtime/src/test/resources/log4j2.properties

5. Update streams

  1. Logging test class changed: LogCaptureAppender → LogCaptureContext
  2. Test logging config changed: streams/src/test/resources/log4j.properties → streams/src/test/resources/log4j2.properties
  3. Add Archetype log4j2 configuration: streams/quickstart/java/src/main/resources/archetype-resources/src/main/resources/log4j2.properties

6. Update streams:test-utils

  1. Test logging config changed: streams/test-utils/src/test/resources/log4j.properties → streams/test-utils/src/test/resources/log4j2.properties

7. Update log4j-appender

  1. Add a resource-closing process to KafkaLog4jAppenderTest methods that use real Kafka Produce object. (It prevents the tests hanging up.)

8. Update raft

  1. Add log4j deprecation message: raft/bin/test-kraft-server-start.sh
  2. Add log4j2 configuration: raft/config/kraft-log4j2.properties

9. Update tests

  - Update tests/kafkatest/services/kafka/kafka.py
    - tests/kafkatest/services/kafka/templates/log4j.properties → log4j2.properties
  - Update tests/kafkatest/services/connect.py
    - tests/kafkatest/services/templates/connect_log4j.properties → connect_log4j2.properties
  - Update tests/kafkatest/services/trogdor/trogdor.py
    - tests/kafkatest/services/trogdor/templates/log4j2.properties → log4j2.properties
  - Update tests/kafkatest/services/streams.py
    - Add tests/kafkatest/services/templates/tools_log4j2.properties
  - Update tests/kafkatest/tests/streams/streams_relational_smoke_test.py
    - tests/kafkatest/tests/streams/templates/log4j_template.properties → log4j2_template.properties

10. Add log4j deprecation messages to the launcher scripts (except tools)

  - bin/connect-distributed.sh
  - bin/connect-mirror-maker.sh
  - bin/connect-standalone.sh
  - bin/kafka-server-start.sh
  - bin/zookeeper-server-start.sh
  - bin/windows/connect-distributed.bat
  - bin/windows/connect-standalone.bat
  - bin/windows/kafka-server-start.bat
  - bin/windows/zookeeper-server-start.bat

11. Add log4j2 conf properties for broker, and connect launcher scripts

  - config/log4j2.properties
  - config/connect-log4j2.properties

12. Trivial Cleanups

  - Remove redundant method call: Defaults.CompressionType.toString → Defaults.CompressionType
  - Fix typo: the curent root logger level → the current root logger level
…ForLog4jLogLevelsDoesNotWorkWithInvalidConfigs; see KIP-817
@dongjinleekr
Copy link
Contributor Author

Rebased onto the latest trunk.

@dhruvp-8 Sorry for being late. For compatibility reasons, the adoption of this PR is postponed to 4.0. in 3.x, the reloadlog4j will be used instead. You can find out the custom build, patch with log4j2 here - I released the AK 3.1.0 based one this week and working on 3.2.0 based one now.

@Indupa
Copy link

Indupa commented Nov 21, 2022

Hi @dongjinleekr ,

we ran into the issue to run zookeepr and kafka , when we tried to use reload4j instead of log4j in kafka-2.8.1 Package. please find below for more details and could you please help us on how to resolve this issue............?

Issue : Currently we are using Kafka-2.8.1 in which it has log4j vulnerabilities reported .
Fix : So we tried to use reload4j-1.2.22 in kafka-2.8.1 to overcome all the vulnerabilities reported by log4j-1.2.1 and made the changes to point to reload4j instead of log4j as its done kafka 3.2.1 latest version
Below are the 2 files in kafka which we made changes to replace log4j with reload4j.

  1. Build.gradle
  2. dependencies.gradle

After pointing to reload4j, its failing to run kafka and zookeeper with below errors.

zookeeper.log
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:630)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.(QuorumPeerMain.java:68)
log4j:ERROR Could not instantiate appender named "kafkaAppender".
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:652)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:518)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.(QuorumPeerMain.java:68)
log4j:ERROR Could not instantiate appender named "requestAppender".
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:652)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:518)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.(QuorumPeerMain.java:68)
log4j:ERROR Could not instantiate appender named "authorizerAppender".
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:652)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:518)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.(QuorumPeerMain.java:68)
log4j:ERROR Could not instantiate appender named "controllerAppender".
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:652)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:518)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.(QuorumPeerMain.java:68)
log4j:ERROR Could not instantiate appender named "requestAppender".
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:652)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:518)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.(QuorumPeerMain.java:68)
log4j:ERROR Could not instantiate appender named "cleanerAppender".
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:652)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:518)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.(QuorumPeerMain.java:68)
log4j:ERROR Could not instantiate appender named "stateChangeAppender".

kafka.log

log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:630)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at com.typesafe.scalalogging.Logger$.apply(Logger.scala:48)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala:25)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala)
at kafka.utils.Logging.$init$(Logging.scala:47)
at kafka.Kafka$.(Kafka.scala:30)
at kafka.Kafka$.(Kafka.scala)
at kafka.Kafka.main(Kafka.scala)
log4j:ERROR Could not instantiate appender named "kafkaAppender".
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:652)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:518)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at com.typesafe.scalalogging.Logger$.apply(Logger.scala:48)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala:25)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala)
at kafka.utils.Logging.$init$(Logging.scala:47)
at kafka.Kafka$.(Kafka.scala:30)
at kafka.Kafka$.(Kafka.scala)
at kafka.Kafka.main(Kafka.scala)
log4j:ERROR Could not instantiate appender named "requestAppender".
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:652)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:518)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at com.typesafe.scalalogging.Logger$.apply(Logger.scala:48)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala:25)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala)
at kafka.utils.Logging.$init$(Logging.scala:47)
at kafka.Kafka$.(Kafka.scala:30)
at kafka.Kafka$.(Kafka.scala)
at kafka.Kafka.main(Kafka.scala)
log4j:ERROR Could not instantiate appender named "authorizerAppender".
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:652)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:518)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at com.typesafe.scalalogging.Logger$.apply(Logger.scala:48)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala:25)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala)
at kafka.utils.Logging.$init$(Logging.scala:47)
at kafka.Kafka$.(Kafka.scala:30)
at kafka.Kafka$.(Kafka.scala)
at kafka.Kafka.main(Kafka.scala)
log4j:ERROR Could not instantiate appender named "controllerAppender".
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:652)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:518)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at com.typesafe.scalalogging.Logger$.apply(Logger.scala:48)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala:25)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala)
at kafka.utils.Logging.$init$(Logging.scala:47)
at kafka.Kafka$.(Kafka.scala:30)
at kafka.Kafka$.(Kafka.scala)
at kafka.Kafka.main(Kafka.scala)
log4j:ERROR Could not instantiate appender named "requestAppender".
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:652)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:518)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at com.typesafe.scalalogging.Logger$.apply(Logger.scala:48)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala:25)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala)
at kafka.utils.Logging.$init$(Logging.scala:47)
at kafka.Kafka$.(Kafka.scala:30)
at kafka.Kafka$.(Kafka.scala)
at kafka.Kafka.main(Kafka.scala)
log4j:ERROR Could not instantiate appender named "cleanerAppender".
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738)
at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:652)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:518)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504)
at org.apache.log4j.LogManager.(LogManager.java:119)
at org.slf4j.impl.Reload4jLoggerFactory.(Reload4jLoggerFactory.java:67)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at com.typesafe.scalalogging.Logger$.apply(Logger.scala:48)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala:25)
at kafka.utils.Log4jControllerRegistration$.(Logging.scala)
at kafka.utils.Logging.$init$(Logging.scala:47)
at kafka.Kafka$.(Kafka.scala:30)
at kafka.Kafka$.(Kafka.scala)
at kafka.Kafka.main(Kafka.scala)
log4j:ERROR Could not instantiate appender named "stateChangeAppender".

could you please help us if we made the changes to those 2 gradle files , is it enought to make kafka-2.8.1 to work using reload4j............?

@ceki
Copy link

ceki commented Nov 21, 2022

@Indupa The correct fully qualified class name for RollingFileAppender is org.apache.log4j.RollingFileAppender and not org.apache.log4j.rolling.RollingFileAppender.

@mimaison
Copy link
Member

mimaison commented Oct 1, 2024

@dongjinleekr We're now accepting changes for 4.0 in trunk. Do you think you can rebase this PR? If not, let us know so someone can complete this work. Thanks.

@ppkarwasz
Copy link

@mimaison,

What is the ETA for 4.0? I might be able to look at it mid-November.

@mimaison
Copy link
Member

We're actively working on it in #17373. Hopefully that will be complete for 4.0.0.

@dongjinleekr
Copy link
Contributor Author

@mimaison @ppkarwasz @ceki

Sorry for being late. I have been very busy nowadays and just got some free time by this end of the year.

@frankvicky

Thanks for taking the issue. I will join the PR and follow up for the review & improvements. Let's close this PR and continue on #17373! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.